/*!
 * nodeclub - route.js
 * Copyright(c) 2012 fengmk2 <fengmk2@gmail.com>
 * MIT Licensed
 */

/**
 * Module dependencies.
 */
import express from 'express';
import * as sign from './controllers/sign';
import * as page from './controllers/page';
import * as script from './controllers/script';
import { zonesRequired } from './middlewares/base_data';
import { authRequired, supportRequired, adminRequired, userRequired } from './middlewares/auth';

const router = express.Router();

router.get('/', zonesRequired, page.indexPage);

router.get('/signup', zonesRequired, page.signupPage);                         // 注册页面
router.get('/signin', zonesRequired, page.signinPage);                         // 登录页面

router.get('/user/searchPasswordFromMail', zonesRequired, page.searchPasswordFromMailPage); 	       // 从邮箱找回密码的链接
router.get('/user/inputPasswordFromMail', zonesRequired, page.inputSearchPasswordPage);             // 从邮箱找回密码的页面
router.get('/user/resetPassword', userRequired, zonesRequired, page.resetPasswordPage);     // 进入重置密码页面

// user controller
router.get('/user/activeAccount', zonesRequired, sign.activeAccount);               // 帐号激活
router.get('/user/setting/show', userRequired, zonesRequired, page.settingPage);       // 用户个人设置页
router.get('/user/:name/show', zonesRequired, page.userPage);                 // 用户个人主页
router.get('/user/:name/topics', zonesRequired, page.userTopicsPage);              // 用户发布的所有话题页
router.get('/user/:name/replies', zonesRequired, page.userRepliesPage);         // 用户参与的所有回复页
router.get('/user/:name/collectTopics', zonesRequired, page.userCollectTopicsPage);               // 用户收藏的话题页面
router.get('/user/messages', userRequired, zonesRequired, page.myMessagesPage);      // 用户个人的所有消息页
router.get('/user/messages/all', userRequired, zonesRequired, page.allMessagePage);

// zone
router.get('/zone/:key/:template', zonesRequired, page.zonePage);
router.get('/zone/:key/:template/topic/:id/show', zonesRequired, page.showTopicPage);          // 显示某个话题
router.get('/zone/:key/:template/topic/create', userRequired, zonesRequired, page.createTopicPage);       // 创建话题页面
router.get('/zone/:ley/:template/topic/:id/edit', userRequired, zonesRequired, page.editTopicPage);        // 编辑话题页面

// cms
router.get('/cms/index', supportRequired, zonesRequired, page.cmsPage);          // cms页面
router.get('/cms/menu', adminRequired, zonesRequired, page.cmsMenuPage);
router.get('/cms/user', adminRequired, zonesRequired, page.cmsUserPage);
router.get('/cms/profile', adminRequired, page.cmsProfilePage);
router.get('/cms/audio', adminRequired, page.cmsAudioPage);
router.get('/cms/static', adminRequired, page.cmsStaticPage);
router.get('/cms/script', adminRequired, zonesRequired, script.scriptPage);       // cms页面
router.get('/cms/script/action', adminRequired, zonesRequired, script.action);       // cms页面

// static
router.get('/static/:name/show', zonesRequired, page.staticPage);
router.get('/static/create', zonesRequired, page.createStaticPage);
router.get('/static/:name/edit', zonesRequired, page.editStaticPage);

// repo
router.get('/repo/index', zonesRequired, page.repoPage);
router.get('/cms/repo/config', adminRequired, zonesRequired, page.repoConfigPage);

export default router;
